home *** CD-ROM | disk | FTP | other *** search
/ Windows 32-Bit Gallery / Windows 32-bit Gallery.iso / win95 / winbatch / install.wb_ < prev    next >
Text File  |  1996-11-20  |  6KB  |  245 lines

  1. ; To actually use and distribute this code as an install program, then either each
  2. ; user must have WinBatch installed on their PC, or the WBT file must be compiled
  3. ; with the Winbatch Compiler.   This sample provided for evaluation only
  4.  
  5.  
  6.  
  7.  
  8. a1="This is a sample wbt file that shows how to code an install program in WinBatch."
  9. a2="In this code, the 'FileCopy' statements that would do the actual install"
  10. a3="have been commented out, so that you can run this sample to see what a "
  11. a4="Winbatch-based install program might look like without really copying any"
  12. a5="files at all."
  13. a6="It will make a Program Manager group to demo the ability to manage Program "
  14. a7="Manager (or other shell) icons.  Just delete the group after the demo."
  15.  
  16. a1=strcat(a1,@crlf,@crlf,a2,@crlf,a3,@crlf,a4,@crlf,a5,@crlf,@crlf,a6,@crlf,a7,@crlf)
  17.  
  18. Message("Install-O-Batch",a1)
  19.  
  20.  
  21. ;Install-o-Batch
  22. ;A Winbatch software installer
  23. ;this wbt file is designed to be compiled and
  24. ;run off of a floppy disk
  25.  
  26. ; Who am us anyways
  27. InstallName="Acme Knickerbockers, Inc."
  28.  
  29. ; Specify default destination directory
  30. DestDir="C:\ACMEAPP\"      ; <<< We need and assume trailing \'s
  31. SrcDir="A:\"                   ; <<< Ditto
  32.  
  33. ; Specify files to install.  Start at file 1.  No skips in numbers
  34. File1="potatoe.fry"       ; CHOOSE FILE 0 so that it HAS AN EXTENSION ( 'fry'  in this case )
  35. file2="Carrot.cak"
  36. file3="Peas.pod"
  37. file4="cornbeef.cab"
  38. file5="toast.jam"
  39. file6="readme"
  40.  
  41.  
  42. ; Now we get busy
  43.  
  44. gosub SetupSplash
  45.  
  46. WhereWe=DirGet()
  47.  
  48.  
  49. gosub VerifySrcDir
  50.  
  51. gosub VerifyDestDir
  52.  
  53. ; Figure out how many files we have for user display
  54. for filenum=1 to 1000
  55.    if !IsDefined(File%filenum%) then break   ; all doned
  56. next
  57.  
  58. filenum=filenum-1
  59.  
  60. for i=1 to filenum
  61.    src=strupper(strcat(SrcDir,File%i%))
  62.    dst=strupper(strcat(DestDir,File%i%))
  63.    BoxText(strcat("Installing file ",i," of ",filenum,@crlf,@crlf,"Copying",@crlf,@tab,src,@crlf,"To",@crlf,@tab,dst))
  64.    ; FileCopy(src,dst,0)          ; the commented out FileCopy
  65.    Delay(Random(6)+1)             ; Fake delay to simulate FileCopy
  66. next
  67.  
  68. ; Set up program group now
  69. ; Use the handy progman.wil file
  70.  
  71. File1="Clock.exe"
  72. File2="Calc.Exe"
  73.  
  74. Call("progman.wil","AddGroup '%InstallName%'")
  75. Call("progman.wil","AddIcon '%InstallName%' '%File1%' 'Acme Clock'")
  76. Call("progman.wil","AddIcon '%InstallName%' '%File2%' 'Acme Calculator'")
  77. if WinExist("Program Manager") then WinIconize("Program Manager")
  78.  
  79.  
  80. Message(InstallName,"Install Complete")
  81.  
  82. gosub UnSplash
  83.  
  84. exit
  85.  
  86. :Cancel
  87. Gosub Unsplash
  88. exit
  89.  
  90. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  91. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  92. ;SetupSplash iconizes all windows, remembers current wallpaper
  93. ; and installs our wallpaper
  94. :setupsplash
  95. OrigWallpaperName=WinparmGet(10)
  96. OrigWallpaperTile=IniRead("Desktop","TileWallpaper",0)
  97. WallPaper("splash.bmp",1 )
  98. OrigWindowList=WinItemize()   ;Get list of all open Windows
  99. OrigWindowCount=ItemCount(OrigWindowList,@tab)
  100. for i=1 to OrigWindowCount
  101.     a=ItemExtract(i,OrigWindowList,@tab)
  102.     b = WinState(a)
  103.     OrigWindowState%i% = b
  104.     ; Note we could hide the other windows here, but if the install
  105.     ; bombs kind of bad, it leaves the user in a lurch and they
  106.     ; got to reboot.  Bad news.  With icons they can always recover
  107.     ; by themselves.
  108.     if b!=@HIDDEN && b!=@ICON && WinExist(a) then WinIconize(a)
  109. next
  110. WinPlaceSet(@NORMAL,"","300 20 700 220")
  111. BoxOpen(InstallName,"Install Initializing.  Please wait")
  112.  
  113. return
  114. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  116. ;UnSplash undoes Setup Splash
  117. :UnSplash
  118. ErrorMode(@off)
  119. for i= OrigWindowCount to 1 by -1
  120.     a=ItemExtract(i,OrigWindowList,@tab)
  121.      switch OrigWindowState%i%
  122.         case @HIDDEN
  123.            break
  124.         case @NORMAL
  125.            WinShow(a)
  126.            break
  127.         case @ICON
  128.            break
  129.         case @ZOOMED
  130.            WinZoom(a)
  131.            break
  132.      end switch
  133. next
  134. ErrorMode(@cancel)
  135. WallPaper(OrigWallPaperName,OrigWallpaperTile)
  136. return;
  137.  
  138.  
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141. :VerifyDestDir
  142.  
  143. BoxText("Verifying Destination Directory")
  144.  
  145. TryDest=strupper(AskLine(InstallName,"Enter destination directory or accept default",DestDir))
  146.  
  147. ;Make sure there is a \ on the end
  148. a=strsub(TryDest,strlen(TryDest),1)
  149. if a!="\" then TryDest=strcat(TryDest,"\")
  150.  
  151. ;If it exists, go home
  152. if DirExist(TryDest)
  153.    DestDir=TryDest
  154.    return
  155. endif
  156.  
  157.  
  158. ; Is user real sure?
  159. a=AskYesNo("InstallName",strcat("Directory ",TryDest,@crlf,"Does not exist.  Create Directory?"))
  160. if a==@NO then goto VerifyDestDir
  161.  
  162. ; We have to chop up the directory name and insure each part exists
  163. ; and if not, create them one at a time.
  164.  
  165. Count=1
  166. WorkDir=TryDest
  167. While @TRUE
  168.    a=strsub(WorkDir,1,strlen(WorkDir)-1)
  169.    DirPart%Count%=FileRoot(a)
  170.    ;Did unbelievable user specify an extension for the directory???
  171.    b=FileExtension(a)
  172.    if b!="" then DirPath%Count% = strcat(DirPart%Count%,".",b)
  173.    WorkDir=FilePath(a)
  174.    if strlen(WorkDir)<=3 then break
  175.    Count=Count+1
  176. endwhile
  177.  
  178. ; got all the pieces now, build the directory
  179.  
  180. for i=Count to 1 by -1
  181.    if !DirExist(WorkDir) then DirMake(WorkDir)
  182.    WorkDir=strcat(WorkDir,DirPart%i%,"\")
  183. next
  184.  
  185. ;Make final piece
  186. DirMake(WorkDir)
  187.  
  188. DestDir=TryDest
  189. Return
  190.  
  191. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  192. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  193. :VerifySrcDir
  194.  
  195. BoxText("Verifying Source Directory")
  196.  
  197. Delay(1)                       ; remove for production version
  198. return                         ; remove for production version
  199.  
  200. SrcDir=DirGet()                ; Get current directory.
  201. b=strcat(SrcDir,file1)         ; Get file name of first file
  202.  
  203. while !FileExist(b)
  204.    d=strupper(File1)
  205.    BoxText("Please select file %d% in source directory%@CRLF%to assist Install-O-Batch in locating source directory.")
  206.    b=strcat("*.",FileExtension(d))
  207.    a=AskFileName("Please locate %d%","","%b%|%b%|",b,1)
  208.    SrcDir=FilePath(a)
  209.    b=strcat(SrcDir,file1)       ; Get file name of first file
  210. endwhile
  211.  
  212. return
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.